/**
 * 
 */
package contacts530.dao1;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import contacts530.dao1.impl.StudentsDaoImpl;
import contacts530.db.Dbconnection;
import contacts530.po.Room;
import contacts530.po.Students;

/**
 * @author zhaoyana
 *
 */
public interface RoomDao {
	Connection conn=Dbconnection.getConnection();
	public void update(Room room);//数据库专用更新接口
	public void update(int room_id); //该接口用于文件/内存存储，id为list的index
	public Room  get(String room_no);
	public void delete(int room_id);

	public static List<Room> findAll(){
		List<Room> roomList =roomList= new ArrayList<Room>();
		PreparedStatement ps=null;
		ResultSet rs=null;
		String sql="select room_no from room";
		try {
			ps=conn.prepareStatement(sql);
			rs=ps.executeQuery();
			while(rs.next()) {
				String roomNo=rs.getString(1);
				int roomId=rs.getInt(2);
				Room room =new Room(roomNo,roomId);
				roomList.add(room);
			}
		}catch (SQLException e) {
			e.printStackTrace();
		}finally {
			Dbconnection.close(rs, ps);
		}
		return roomList;
		
	}
	/**
	 * @param student
	 */
	void save(Room room);
}
